package JUC;

import java.util.concurrent.atomic.LongAccumulator;
import java.util.concurrent.atomic.LongAdder;

/**
 * @author 曹见朋
 * @create 2024-07-03-21:34
 */
public class LongAddrDemo {
    public static void main(String[] args) {
        LongAdder longAdder = new LongAdder();
        longAdder.increment();
        longAdder.increment();
        longAdder.increment();
        longAdder.increment();
        String s = longAdder.toString();
        System.out.println(s);

        LongAccumulator longAccumulator = new LongAccumulator((x, y)-> x + y, 0);

        longAccumulator.accumulate(1);
        longAccumulator.accumulate(1);
        longAccumulator.accumulate(1);
        longAccumulator.accumulate(1);
        System.out.println(longAccumulator.get());
    }
}
